package cn.lingyangwl.agile.infra.module.dict.model.rqrs;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import cn.lingyangwl.agile.model.module.dict.CusFieldBind;
import cn.lingyangwl.agile.model.module.dict.DictTypeCons;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author shenguangyang
 */
@Data
public class DictResp implements Serializable {
    private static final long serialVersionUID = 1L;
    @ExcelIgnore
    private Long id;

    /** 字典名称 */
    @Excel(name = "字典名称", width = 30)
    private String dictName;

    /** 字典编码 */
    @Excel(name = "字典编码", width = 20)
    private String dictCode;

    /** 字典组 */
    @Excel(name = "字典组", width = 20)
    private String dictGroup;

    /** 状态（1正常 2停用） */
    @Excel(name = "状态", dict = DictTypeCons.DICT_ITEM_STATUS, width = 20)
    @CusFieldBind(type = DictTypeCons.DICT_ITEM_STATUS, target = "statusText")
    private String status;

    /** 绑定显示属性，非表字典（排除） */
    @ExcelIgnore
    private String statusText;


    /** 字典编码 */
    @NotBlank(message = "字典编码不能为空")
    @Size(min = 1, max = 100, message = "字典编码长度不能超过100个字符")
    private Long groupId;

    /** 字典组名称 */
    private String groupName;

    /**
     * 创建者
     */
    @ExcelIgnore
    private String createdBy;

    /**
     * 创建时间
     */
    @ExcelIgnore
    private Date createdAt;

    /**
     * 更新者
     */
    @ExcelIgnore
    private String updatedBy;

    /**
     * 更新时间
     */
    private Date updatedAt;

    /**
     * 备注
     */
    @Excel(name = "备注", width = 50)
    private String remark;

    @ExcelCollection(name = "字典条目")
    private List<DictItemResp> dictItemList;

    public String getLabel() {
        return dictName;
    }

    public String getValue() {
        return dictCode;
    }
}
